package com.ethan.guava;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.*;

import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ethan
 * create 2018-04-22 下午6:34
 * desc
 **/
public class MapsTest {
    public static void main(String[] args){
//        map = Maps.uniqueIndex(baseOrderDetailsList, new Function<BaseOrderDetails, String>() {
//            @Override
//            public String apply(BaseOrderDetails input) {
//                return input.getOrderNo();
//            }
//        });


        List<Student> list = Lists.newArrayList(new Student(1,"aa"),new Student(2,"bb")
                ,new Student(3,"cc"),new Student(4,"cc"));


        Map<String,Student> map = Maps.uniqueIndex(list, new Function<Student, String>() {
            @Nullable
            @Override
            public String apply(@Nullable Student student) {
                return student.getName();
            }
        });

        String a="";

    }

    @Getter
    @Setter
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class Student{
        private int id;
        private String name;
    }
}
